<?php
/**
 * @package Joomla
 * @subpackage Jmonoslideshow
 * @copyright (C) 2010 - Matthieu BARBE - www.ccomca.com
 * @license GNU/GPL v2
 * 
 * Jmonoslideshow is a Joomla extension for Monoslideshow.
 *
 * Jmonoslideshow uses :
 * Monoslideshow (http://www.monoslideshow.com/)
 * Plupload (http://www.plupload.com/) by Moxicode Systems
 * json class by Michal Migurski, Matt Knapp, Brett Stimmerman
 * jquery a JavaScript Library (http://jquery.com/)
 * getid3 library (http://getid3.sourceforge.net/)
 * swfobject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file (http://code.google.com/p/swfobject/)
 * Chained Selects jQuery Plugin (http://www.appelsiini.net/2010/jquery-chained-selects)
 *
 * Jmonoslideshow is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );


/**
 * Category Table class
 *
 * @package    Jmonsoslideshow
 * @subpackage Components
 */
class TableCategory extends JTable
{
	/**
	 * Primary Key
	 *
	 * @var int
	 */
	var $id = null;

	/**
	 * @var string
	 */
	var $title = null;
	
	/**
	 * @var string
	 */
	var $description = null;
	
	/**
	 * @var int
	 */
	var $author = null;
	
	/**
	 * @var date
	 */
	var $created = null;
	
	/**
	 * @var date
	 */
	var $modified = null;
	
	/**
	 * @var int
	 */
	var $modified_by = null;
	
	
	/**
	 * @var id
	 */
	var $checked_out = null;
	
	/**
	 * @var date
	 */
	var $checked_out_time = null;
	
	/**
	 * @var id
	 */
	var $published = null;
	
	/**
	 * @var id
	 */
	var $ordering = null;
	
	/**
	 * @var text
	 */
	var $params = null;

	/**
	 * Constructor
	 *
	 * @param object Database connector object
	 */
	function TableCategory(& $db) {
		parent::__construct('#__monoslideshow_category', 'id', $db);
	}
	
	/**
	* Overloaded bind function
	*
	* @acces public
	* @param array $hash named array
	* @return null|string	null is operation was satisfactory, otherwise returns an error
	* @see JTable:bind
	* @since 1.5
	*/
	function bind($array, $ignore = '')
	{
		if (key_exists( 'params', $array ) && is_array( $array['params'] ))
		{
			$registry = new JRegistry();
			$registry->loadArray($array['params']);
			$array['params'] = $registry->toString();
		}

		return parent::bind($array, $ignore);
	}
	
	 function check()
	{
		
		if(  $this->title == "" ) {
			
		    $this->setError( JText::_('You must enter a title') );
			return false;
			
		}
		
		$user =& JFactory::getUser();
		
		
		$this->modified_by = $user->get('id');
		$this->modified = date('Y-m-d H:i:s');
		
		
		if ( !$this->id ) {	
        	$this->author = $user->get('id');
			$this->created = date('Y-m-d H:i:s');
			
			$this->ordering = $this->getNextOrder(  );
			$this->published = 1;
        }
		
		return true;
	}
}
?>